﻿<%@ Page Language="C#" MasterPageFile="~/Plantillanoheader.master" AutoEventWireup="true" CodeFile="VerArticulos.aspx.cs" Inherits="PagComunes_VerArticulos" %>
<%@ Register Src="~/controles/RatingDisplay.ascx" TagName="RatingDisplay" TagPrefix="iuap" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="headerslider" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="bodyprincipal" Runat="Server">
   <div class="articlebox">
      <table style="width: 100%;">
         <tr>
         <td>
            <asp:Label runat="server" ID="lblTitle" CssClass="articletitle" /> 
            <asp:Label runat="server" ID="lblNotApproved" Text="No se ha aprobado" SkinID="NotApproved" /> 
         </td>
         <td style="text-align: right;">
            <asp:Panel runat="server" ID="panEditArticle">
            <asp:ImageButton runat="server" ID="btnApprove"
               CausesValidation="false" AlternateText="Aprobar el artículo" ImageUrl="~/Images/checkmark.gif" 
               OnClientClick="if (confirm('¿Está seguro que desea aprobar este artículo?') == false) return false;" OnClick="btnApprove_Click" />
            &nbsp;
            <asp:HyperLink runat="server" ID="lnkEditArticle" ImageUrl="~/Images/Edit.gif"
               ToolTip="Editar Artículo" NavigateUrl="~/PagAdmin/AddEditArticulos.aspx?ID={0}" />
            &nbsp;
            <asp:ImageButton runat="server" ID="btnDelete"
               CausesValidation="false" AlternateText="Borrar Artículo" ImageUrl="~/Images/Delete.gif" 
               OnClientClick="if (confirm('¿Está seguro que desea eliminar este artículo?') == false) return false;" OnClick="btnDelete_Click" /></asp:Panel>
         </td></tr>
      </table>      
       <b>Votación: </b><asp:Literal runat="server" ID="lblRating" Text="{0} usuario (s) han calificado este artículo " />
      <iuap:RatingDisplay runat="server" ID="ratDisplay" />
      <br />
       
      <b>Publicado por: </b> <asp:Literal runat="server" ID="lblAddedBy" />,
      el <asp:Literal runat="server" ID="lblReleaseDate" />, 
      en la categoría "<asp:Literal runat="server" ID="lblCategory" />"
      <br />
       <b>Vistas: </b><asp:Literal runat="server" ID="lblViews" Text="Este artículo ha sido leído {0} veces" />      
      <asp:Literal runat="server" ID="lblLocation" Text="<br /><b>Lugar: </b>{0}" />
      <br />
      <div class="articleabstract">
       <b>Resumen: </b> <asp:Literal runat="server" ID="lblAbstract" />
      </div>
   </div>
   <p></p>
   <asp:Literal runat="server" ID="lblBody" />
   <p></p>
   <hr style="width: 100%; height: 1px;" noshade="noshade" />
   <br />
   <h4 class="txt1">¿Cómo calificaría este artículo?</h4>
   <asp:DropDownList runat="server" ID="ddlRatings" CssClass="genselect">
      <asp:ListItem Value="1" Text="1 uap" />
      <asp:ListItem Value="2" Text="2 uaps" />
      <asp:ListItem Value="3" Text="3 uaps" />
      <asp:ListItem Value="4" Text="4 uaps" />
      <asp:ListItem Value="5" Text="5 uaps" Selected="true" />
   </asp:DropDownList>
   <asp:Button runat="server" ID="btnRate" Text="Calificar" OnClick="btnRate_Click" CausesValidation="false" CssClass="submitpequeno"/>
   <asp:Literal runat="server" ID="lblUserRating" Visible="False"
      Text="Su clasificación para este artículo {0} uap (s). Gracias por su colaboración." />
   <p></p>
   <hr style="width: 100%; height: 1px;" noshade="noshade" />
   <p></p>
   <asp:Panel runat="server" ID="panComments" BorderStyle="None">
   <h3>Comentarios</h3>
   <asp:DataList ID="dlstComments" runat="server" DataSourceID="objComments" DataKeyField="ID" OnSelectedIndexChanged="dlstComments_SelectedIndexChanged" OnItemCommand="dlstComments_ItemCommand">
      <ItemTemplate>
         <div class="comment">
         <table style="width: 100%;">
         <tr><td>
         <b>Comentario publicado por:
            <asp:HyperLink ID="lnkAddedBy" runat="server" Text='<%# Eval("Usuario") %>'
               NavigateUrl='<%# "mailto:" + Eval("Mail_usua_come") %>' />
            el <asp:Literal ID="lblAddedDate" runat="server" Text='<%# Eval("Fecha", "{0:f}") %>' />            
         </b>
         </td>
         <td style="text-align: right;">
            <asp:Panel runat="server" ID="panAdmin" Visible='<%# UserCanEdit %>'>
            <asp:ImageButton runat="server" ID="btnSelect" CommandName="Select"
               CausesValidation="false" AlternateText="Editar Comentario" ImageUrl="~/Images/Edit.gif"  />
            &nbsp;&nbsp;
            <asp:ImageButton runat="server" ID="btnDelete" CommandName="Delete" CommandArgument='<%# Eval("ID") %>'
               CausesValidation="false" AlternateText="Borrar Comentario" ImageUrl="~/Images/Delete.gif"
               OnClientClick="if (confirm('¿Está seguro que desea eliminar este comentario?') == false) return false;" />
            </asp:Panel>
         </td></tr>
         </table>
         <asp:Literal ID="lblBody" runat="server" Text='<%# Eval("EncodedBody") %>' />         
         </div>
         <br />
      </ItemTemplate>
   </asp:DataList><asp:ObjectDataSource ID="objComments" runat="server" SelectMethod="GetComments"
      TypeName="IUAP.BLL.Articulo.Comentario">
      <SelectParameters>
         <asp:QueryStringParameter DefaultValue="0" Name="id_articulo" QueryStringField="ID" Type="Int32" />
      </SelectParameters>
   </asp:ObjectDataSource>
   <hr style="width: 100%; height: 1px;" noshade="noshade" />
   <p></p>
   <h4 class="txt1">Publicar tu comentario</h4>
   <div class="boxcoment" id="boxcomment">
   <asp:DetailsView id="dvwComment" runat="server" AutoGenerateInsertButton="True" AutoGenerateEditButton="true" AutoGenerateRows="False" DataSourceID="objCurrComment" DefaultMode="Insert" OnItemInserted="dvwComment_ItemInserted" OnItemCommand="dvwComment_ItemCommand" DataKeyNames="ID" OnItemUpdated="dvwComment_ItemUpdated" OnItemCreated="dvwComment_ItemCreated" BorderStyle="None" CellPadding="5" CellSpacing="10" BorderWidth="0" AlternatingRowStyle-BorderStyle="None" CommandRowStyle-BorderStyle="None" EditRowStyle-BorderStyle="None" EmptyDataRowStyle-BorderStyle="None" FieldHeaderStyle-BorderStyle="None" FooterStyle-BorderStyle="None" HeaderStyle-BorderStyle="None" InsertRowStyle-BorderStyle="None" PagerStyle-BorderStyle="None" RowStyle-BorderStyle="None" AlternatingRowStyle-BorderWidth="0" CommandRowStyle-BorderWidth="0" EditRowStyle-BorderWidth="0" EmptyDataRowStyle-BorderWidth="0" FieldHeaderStyle-BorderWidth="0" FooterStyle-BorderWidth="0" HeaderStyle-BorderWidth="0" InsertRowStyle-BorderWidth="0" PagerStyle-BorderWidth="0" RowStyle-BorderWidth="0" RowStyle-CssClass="boxcomenttr">
       <AlternatingRowStyle BorderStyle="None" BorderWidth="0px" />
       <CommandRowStyle BorderStyle="None" BorderWidth="0px" />
       <EditRowStyle BorderStyle="None" BorderWidth="0px" />
       <EmptyDataRowStyle BorderStyle="None" BorderWidth="0px" />
      <FieldHeaderStyle BorderStyle="None" BorderWidth="0" CssClass="boxcomenttr" />      
      <Fields>
         <asp:BoundField DataField="ID" HeaderText="ID:" ReadOnly="True" 
              InsertVisible="False" ControlStyle-BorderStyle="None" 
              FooterStyle-BorderStyle="None" HeaderStyle-BorderStyle="None" 
              ItemStyle-BorderStyle="None" HeaderStyle-CssClass="txt1"> 
          </asp:BoundField>
         <asp:BoundField DataField="Fecha" HeaderText="Fecha:" InsertVisible="False" ReadOnly="True" HeaderStyle-CssClass="txt1">
         </asp:BoundField>
         <asp:TemplateField HeaderText="Nombre:" ControlStyle-BorderStyle="None" ControlStyle-BorderWidth="0" FooterStyle-BorderStyle="None" FooterStyle-BorderWidth="0" HeaderStyle-BorderStyle="None" HeaderStyle-BorderWidth="0" ItemStyle-BorderStyle="None" ItemStyle-CssClass="boxcomenttr" HeaderStyle-CssClass="txt1">
            <ItemTemplate>
               <asp:Label ID="lblAddedBy" runat="server" Text='<%# Eval("Usuario") %>' />
            </ItemTemplate>
            <InsertItemTemplate >
               <asp:TextBox ID="txtAddedBy" runat="server" Text='<%# Bind("Usuario") %>' MaxLength="256" Width="100%"></asp:TextBox>
               <asp:RequiredFieldValidator ID="valRequireAddedBy" runat="server" ControlToValidate="txtAddedBy" SetFocusOnError="true"
                  Text="Su nombre es obligatorio." ToolTip="Su nombre es obligatorio." Display="Dynamic" CssClass="error"></asp:RequiredFieldValidator>            
            </InsertItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="E-mail:" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" FooterStyle-BorderStyle="None" ControlStyle-BorderStyle="None" HeaderStyle-CssClass="txt1">
            <ItemTemplate>
               <asp:HyperLink ID="lnkAddedByEmail" runat="server" Text='<%# Eval("Mail_usua_come") %>'
                  NavigateUrl='<%# "mailto:" + Eval("Mail_usua_come") %>' />
            </ItemTemplate>
            <InsertItemTemplate>
               <asp:TextBox CssClass="textbox" ID="txtAddedByEmail" runat="server" Text='<%# Bind("Mail_usua_come") %>' MaxLength="256" Width="100%"></asp:TextBox>
               <asp:RequiredFieldValidator ID="valRequireAddedByEmail" runat="server" ControlToValidate="txtAddedByEmail" SetFocusOnError="true"
                  Text="Tu e-mail es necesario." ToolTip="Tu e-mail es necesario." Display="Dynamic" CssClass="error"></asp:RequiredFieldValidator>
               <asp:RegularExpressionValidator runat="server" ID="valEmailPattern"  Display="Dynamic" SetFocusOnError="true"
                  ControlToValidate="txtAddedByEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                  Text="El e-mail no está bien formado." ToolTip="El e-mail no está bien formado." CssClass="error" />
            </InsertItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Comentario:" ControlStyle-BorderStyle="None" FooterStyle-BorderStyle="None" HeaderStyle-BorderStyle="None" ItemStyle-BorderStyle="None" HeaderStyle-CssClass="txt1">
            <ItemTemplate>
               <asp:Label ID="lblBody" runat="server" Text='<%# Eval("Cont_come") %>' />
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox ID="txtBody" runat="server" Text='<%# Bind("Cont_come") %>' TextMode="MultiLine" Rows="5" Width="100%"></asp:TextBox>
               <asp:RequiredFieldValidator ID="valRequireBody" runat="server" ControlToValidate="txtBody" SetFocusOnError="true"
                  Text="El texto del comentario es necesario." ToolTip="El texto del comentario es necesario." Display="Dynamic" CssClass="error"></asp:RequiredFieldValidator>
            </EditItemTemplate>
         </asp:TemplateField>
      </Fields>
   </asp:DetailsView>   
   </div>
   <asp:ObjectDataSource ID="objCurrComment" runat="server" InsertMethod="InsertComment"
      SelectMethod="GetCommentByID" TypeName="IUAP.BLL.Articulo.Comentario"
      UpdateMethod="UpdateComment">
      <UpdateParameters>
         <asp:Parameter Name="id" Type="Int32" />
         <asp:Parameter Name="cont_come" Type="String" />
      </UpdateParameters>
      <SelectParameters>
         <asp:ControlParameter ControlID="dlstComments" Name="id_comentario" PropertyName="SelectedValue"
            Type="Int32" />
      </SelectParameters>
      <InsertParameters>
         <asp:Parameter Name="usuario" Type="String" />
         <asp:Parameter Name="mail_usua_come" Type="String" />
         <asp:QueryStringParameter Name="id_articulo" QueryStringField="ID" Type="Int32" />
         <asp:Parameter Name="cont_come" Type="String" />
      </InsertParameters>
   </asp:ObjectDataSource>
   </asp:Panel>  
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="titulocolum" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="bodycolleft" Runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="bodycolright" Runat="Server">
</asp:Content>
